package com.itcast.Comparable.Demo01;

import java.util.Arrays;
import java.util.Comparator;

/*
要写注释哦!!!
*/
public class Test {
    public static void main(String[] args) {
        Student[] arr = {
                new Student("aaa", 19, 180, 56, 60),
                new Student("bbb", 17, 180, 36, 90),
                new Student("ccc", 17, 181, 76, 70),
                new Student("ddd", 17, 173, 46, 80),
                new Student("eee", 16, 166, 86, 100),
        };
        Arrays.sort(arr, new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                int resout = o1.getAge() - o2.getAge();
                resout = resout == 0 ? o1.getHight() - o2.getHight() : resout;
                resout = resout == 0 ? o1.getHight() - o2.getHight() : resout;
                resout = resout == 0 ? o1.getWeigth() - o2.getWeigth() : resout;
                resout = resout == 0 ? o1.getScore() - o2.getScore() : resout;
                return resout;
            }
        });
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
}
